package com.icss.ah.password.service;

import java.util.HashMap;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.icss.ah.login.bean.UserInfoBean;

@Service
@Transactional
public class PasswordEditService {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	/**
	 * 获取用户基本信息
	 * @param userCode
	 * @return
	 */
	public HashMap getUserInfo(String userCode){
		HashMap userMap = new HashMap();
		try{
			userMap =  (HashMap)sqlSessionTemplate.selectOne("PasswordEditBean.getUserInfo", userCode);
			userMap = userMap == null ? new HashMap() : userMap;
		} catch (Exception e) {
			e.printStackTrace();
			userMap = new HashMap();
		}
		return userMap;
	}
	/**
	 * update模板
	 * @param modelKey
	 * @param map
	 * @return
	 */
	public boolean updatePwd(Map map,String uuidBefore){
		boolean result = false;
		try {
			int f = 0;
			if(uuidBefore.equals("")||uuidBefore==null){
				f = sqlSessionTemplate.update("PasswordEditBean.updatePwdByAccount",map);
			}else{
				f = sqlSessionTemplate.update("PasswordEditBean.updatePwd",map);
			}
			if(f>0){
				result = true;
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		} 
		return result;
	}
	
	
}
